<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
	<script src="../node_modules/axios/dist/axios.js"></script>
</head>
<body>
	<button>发送请求</button>
</body>
<script type="module">
	import axios from "./index.js";
	// request====>handlers===>[
	//    {fulfilled:请求拦截1成功，rejected:请求拦截1失败回调}
	//    {fulfilled:请求拦截2成功，rejected:请求拦截2失败回调}
	// ]
	// response===>handlers===>[
	//      {fulfilled:响应拦截1成功，rjected:响应拦截1失败}
	//      {fulfilled:响应拦截2成功，rjected:响应拦截2失败}
	// ]
	const r1 = axios.interceptors.request.use(function(config){
		console.log("请求拦截1-成功回调");
		return config;
	},()=>{
		console.log("请求拦截1-失败回调")
	})
	const r2 = axios.interceptors.request.use(function(config){
		console.log("请求拦截2-成功回调")
		// throw "异常"
		return config;
	},()=>{
		console.log("请求拦截2-失败回调")
	})
	const s1= axios.interceptors.response.use(function(res){
		console.log("响应拦截1-成功回调")
		return res.data;
	},(err)=>{
		console.log("响应拦截1-失败回调")
	})
	const s2 = axios.interceptors.response.use(function(res){
		console.log("响应拦截2-成功回调")
		return res;
	},()=>{
		console.log("响应拦截2-失败回调")
	})
	// axios.interceptors.request.eject(r1);
	// axios.interceptors.request.eject(r2);
	// axios.interceptors.response.eject(s1);
	// axios.interceptors.response.eject(s2);
	// axios.interceptors.request.clear();// 移除所有的请求拦截
	// axios.interceptors.response.clear();// 移除所有的响应拦截
	document.querySelector("button").onclick = function(){
		axios.get("http://zhangpeiyue.com/scoreList").then(value=>{
			console.log(value);
		})
	}
</script>
</html>